package com.util;


class MenuUtils 
{

    def menuContent = "";    

    /*获得无限级菜单的内容*/
    def getMenuContent(menus)
    {
    	
    	if(menus)
    	{
			for(menu in menus)
			{
				if(menu?.cmenus)
				{
					menuContent += "<li><a class='qmparent' href='javascript:void(0);'>${menu?.menuname}</a><ul>"
					getMenuContent(filterSortMenu(menu?.cmenus));
					menuContent += "</ul></li>"
				}else
				{
					menuContent+= "<li><a class='qmparent' href='javascript:void(0);'>${menu?.menuname}</a></li>"
				}					
			}
    	}
    	
    	return menuContent;
	
    }
    
    //按isstop条件进行过滤，并且按ordernum进行排序
    def filterSortMenu(menus)
    {

    		def menusTemp = menus.findAll{elem-> elem.isstop!=1}
    		def menuResult = menusTemp.sort
    		{
    			a,b->
    			a.ordernum <=> b.ordernum
    		}

    	    return menuResult;
    }
    

}